#include "s_mainwindow.h"
#include "ui_s_mainwindow.h"

#include <QCloseEvent>

#include "../logger/Logger.h"

using namespace Logger;
using namespace Network;

MainWindow::MainWindow(QWidget *parent)
	: QMainWindow(parent), ui(new Ui::MainWindow)
{
	ui->setupUi(this);

	Log & log(Log::get());
	log.addOutput(new OutputText("log.txt"));

	connect(&scontroller, SIGNAL(newMsg(QString, int)), &log, SLOT(onNewMessage(const QString &, int)));

	scontroller.start();
}

MainWindow::~MainWindow()
{
	delete ui;
}

void MainWindow::closeEvent(QCloseEvent *event) {
	scontroller.stop();
	//ncontroller.wait(3000);

	event->accept();
}

void MainWindow::on_pushButton_clicked()
{
	close();
}
